home *** CD-ROM | disk | FTP | other *** search
- package java.io;
-
- class ObjectInputStream$BlockDataInputStream extends InputStream implements DataInput {
- private static final int MAX_BLOCK_SIZE = 1024;
- private static final int MAX_HEADER_SIZE = 5;
- private static final int CHAR_BUF_SIZE = 256;
- private static final int HEADER_BLOCKED = -2;
- private final byte[] buf;
- private final byte[] hbuf;
- private final char[] cbuf;
- private boolean blkmode;
- private int pos;
- private int end;
- private int unread;
- // $FF: renamed from: in java.io.ObjectInputStream.PeekInputStream
- private final ObjectInputStream.PeekInputStream field_0;
- private final DataInputStream din;
- // $FF: synthetic field
- final ObjectInputStream this$0;
-
- ObjectInputStream$BlockDataInputStream(ObjectInputStream var1, InputStream var2) {
- this.this$0 = var1;
- this.buf = new byte[1024];
- this.hbuf = new byte[5];
- this.cbuf = new char[256];
- this.blkmode = false;
- this.pos = 0;
- this.end = -1;
- this.unread = 0;
- this.field_0 = new ObjectInputStream.PeekInputStream(var2);
- this.din = new DataInputStream(this);
- }
-
- boolean setBlockDataMode(boolean var1) throws IOException {
- if (this.blkmode == var1) {
- return this.blkmode;
- } else {
- if (var1) {
- this.pos = 0;
- this.end = 0;
- this.unread = 0;
- } else if (this.pos < this.end) {
- throw new IllegalStateException("unread block data");
- }
-
- this.blkmode = var1;
- return !this.blkmode;
- }
- }
-
- boolean getBlockDataMode() {
- return this.blkmode;
- }
-
- void skipBlockData() throws IOException {
- if (!this.blkmode) {
- throw new IllegalStateException("not in block data mode");
- } else {
- while(this.end >= 0) {
- this.refill();
- }
-
- }
- }
-
- private int readBlockHeader(boolean var1) throws IOException {
- if (ObjectInputStream.access$500(this.this$0)) {
- return -1;
- } else {
- try {
- while(true) {
- int var2 = var1 ? Integer.MAX_VALUE : this.field_0.available();
- if (var2 == 0) {
- return -2;
- }
-
- int var3 = this.field_0.peek();
- switch (var3) {
- case 119:
- if (var2 < 2) {
- return -2;
- }
-
- this.field_0.readFully(this.hbuf, 0, 2);
- return this.hbuf[1] & 255;
- case 120:
- default:
- if (var3 < 0 || var3 >= 112 && var3 <= 126) {
- return -1;
- }
-
- throw new StreamCorruptedException(String.format("invalid type code: %02X", var3));
- case 121:
- this.field_0.read();
- ObjectInputStream.access$600(this.this$0);
- break;
- case 122:
- if (var2 < 5) {
- return -2;
- }
-
- this.field_0.readFully(this.hbuf, 0, 5);
- int var4 = Bits.getInt(this.hbuf, 1);
- if (var4 < 0) {
- throw new StreamCorruptedException("illegal block data header length: " + var4);
- }
-
- return var4;
- }
- }
- } catch (EOFException var5) {
- throw new StreamCorruptedException("unexpected EOF while reading block data header");
- }
- }
- }
-
- private void refill() throws IOException {
- try {
- do {
- this.pos = 0;
- if (this.unread > 0) {
- int var1 = this.field_0.read(this.buf, 0, Math.min(this.unread, 1024));
- if (var1 < 0) {
- throw new StreamCorruptedException("unexpected EOF in middle of data block");
- }
-
- this.end = var1;
- this.unread -= var1;
- } else {
- int var3 = this.readBlockHeader(true);
- if (var3 >= 0) {
- this.end = 0;
- this.unread = var3;
- } else {
- this.end = -1;
- this.unread = 0;
- }
- }
- } while(this.pos == this.end);
-
- } catch (IOException var2) {
- this.pos = 0;
- this.end = -1;
- this.unread = 0;
- throw var2;
- }
- }
-
- int currentBlockRemaining() {
- if (this.blkmode) {
- return this.end >= 0 ? this.end - this.pos + this.unread : 0;
- } else {
- throw new IllegalStateException();
- }
- }
-
- int peek() throws IOException {
- if (this.blkmode) {
- if (this.pos == this.end) {
- this.refill();
- }
-
- return this.end >= 0 ? this.buf[this.pos] & 255 : -1;
- } else {
- return this.field_0.peek();
- }
- }
-
- byte peekByte() throws IOException {
- int var1 = this.peek();
- if (var1 < 0) {
- throw new EOFException();
- } else {
- return (byte)var1;
- }
- }
-
- public int read() throws IOException {
- if (this.blkmode) {
- if (this.pos == this.end) {
- this.refill();
- }
-
- return this.end >= 0 ? this.buf[this.pos++] & 255 : -1;
- } else {
- return this.field_0.read();
- }
- }
-
- public int read(byte[] var1, int var2, int var3) throws IOException {
- return this.read(var1, var2, var3, false);
- }
-
- public long skip(long var1) throws IOException {
- long var3 = var1;
-
- while(var3 > 0L) {
- if (this.blkmode) {
- if (this.pos == this.end) {
- this.refill();
- }
-
- if (this.end < 0) {
- break;
- }
-
- int var7 = (int)Math.min(var3, (long)(this.end - this.pos));
- var3 -= (long)var7;
- this.pos += var7;
- } else {
- int var5 = (int)Math.min(var3, 1024L);
- if ((var5 = this.field_0.read(this.buf, 0, var5)) < 0) {
- break;
- }
-
- var3 -= (long)var5;
- }
- }
-
- return var1 - var3;
- }
-
- public int available() throws IOException {
- if (!this.blkmode) {
- return this.field_0.available();
- } else {
- if (this.pos == this.end && this.unread == 0) {
- int var1;
- while((var1 = this.readBlockHeader(false)) == 0) {
- }
-
- switch (var1) {
- case -2:
- break;
- case -1:
- this.pos = 0;
- this.end = -1;
- break;
- default:
- this.pos = 0;
- this.end = 0;
- this.unread = var1;
- }
- }
-
- int var2 = this.unread > 0 ? Math.min(this.field_0.available(), this.unread) : 0;
- return this.end >= 0 ? this.end - this.pos + var2 : 0;
- }
- }
-
- public void close() throws IOException {
- if (this.blkmode) {
- this.pos = 0;
- this.end = -1;
- this.unread = 0;
- }
-
- this.field_0.close();
- }
-
- int read(byte[] var1, int var2, int var3, boolean var4) throws IOException {
- if (var3 == 0) {
- return 0;
- } else if (this.blkmode) {
- if (this.pos == this.end) {
- this.refill();
- }
-
- if (this.end < 0) {
- return -1;
- } else {
- int var6 = Math.min(var3, this.end - this.pos);
- System.arraycopy(this.buf, this.pos, var1, var2, var6);
- this.pos += var6;
- return var6;
- }
- } else if (var4) {
- int var5 = this.field_0.read(this.buf, 0, Math.min(var3, 1024));
- if (var5 > 0) {
- System.arraycopy(this.buf, 0, var1, var2, var5);
- }
-
- return var5;
- } else {
- return this.field_0.read(var1, var2, var3);
- }
- }
-
- public void readFully(byte[] var1) throws IOException {
- this.readFully(var1, 0, var1.length, false);
- }
-
- public void readFully(byte[] var1, int var2, int var3) throws IOException {
- this.readFully(var1, var2, var3, false);
- }
-
- public void readFully(byte[] var1, int var2, int var3, boolean var4) throws IOException {
- while(var3 > 0) {
- int var5 = this.read(var1, var2, var3, var4);
- if (var5 < 0) {
- throw new EOFException();
- }
-
- var2 += var5;
- var3 -= var5;
- }
-
- }
-
- public int skipBytes(int var1) throws IOException {
- return this.din.skipBytes(var1);
- }
-
- public boolean readBoolean() throws IOException {
- int var1 = this.read();
- if (var1 < 0) {
- throw new EOFException();
- } else {
- return var1 != 0;
- }
- }
-
- public byte readByte() throws IOException {
- int var1 = this.read();
- if (var1 < 0) {
- throw new EOFException();
- } else {
- return (byte)var1;
- }
- }
-
- public int readUnsignedByte() throws IOException {
- int var1 = this.read();
- if (var1 < 0) {
- throw new EOFException();
- } else {
- return var1;
- }
- }
-
- public char readChar() throws IOException {
- if (!this.blkmode) {
- this.pos = 0;
- this.field_0.readFully(this.buf, 0, 2);
- } else if (this.end - this.pos < 2) {
- return this.din.readChar();
- }
-
- char var1 = Bits.getChar(this.buf, this.pos);
- this.pos += 2;
- return var1;
- }
-
- public short readShort() throws IOException {
- if (!this.blkmode) {
- this.pos = 0;
- this.field_0.readFully(this.buf, 0, 2);
- } else if (this.end - this.pos < 2) {
- return this.din.readShort();
- }
-
- short var1 = Bits.getShort(this.buf, this.pos);
- this.pos += 2;
- return var1;
- }
-
- public int readUnsignedShort() throws IOException {
- if (!this.blkmode) {
- this.pos = 0;
- this.field_0.readFully(this.buf, 0, 2);
- } else if (this.end - this.pos < 2) {
- return this.din.readUnsignedShort();
- }
-
- int var1 = Bits.getShort(this.buf, this.pos) & '\uffff';
- this.pos += 2;
- return var1;
- }
-
- public int readInt() throws IOException {
- if (!this.blkmode) {
- this.pos = 0;
- this.field_0.readFully(this.buf, 0, 4);
- } else if (this.end - this.pos < 4) {
- return this.din.readInt();
- }
-
- int var1 = Bits.getInt(this.buf, this.pos);
- this.pos += 4;
- return var1;
- }
-
- public float readFloat() throws IOException {
- if (!this.blkmode) {
- this.pos = 0;
- this.field_0.readFully(this.buf, 0, 4);
- } else if (this.end - this.pos < 4) {
- return this.din.readFloat();
- }
-
- float var1 = Bits.getFloat(this.buf, this.pos);
- this.pos += 4;
- return var1;
- }
-
- public long readLong() throws IOException {
- if (!this.blkmode) {
- this.pos = 0;
- this.field_0.readFully(this.buf, 0, 8);
- } else if (this.end - this.pos < 8) {
- return this.din.readLong();
- }
-
- long var1 = Bits.getLong(this.buf, this.pos);
- this.pos += 8;
- return var1;
- }
-
- public double readDouble() throws IOException {
- if (!this.blkmode) {
- this.pos = 0;
- this.field_0.readFully(this.buf, 0, 8);
- } else if (this.end - this.pos < 8) {
- return this.din.readDouble();
- }
-
- double var1 = Bits.getDouble(this.buf, this.pos);
- this.pos += 8;
- return var1;
- }
-
- public String readUTF() throws IOException {
- return this.readUTFBody((long)this.readUnsignedShort());
- }
-
- public String readLine() throws IOException {
- return this.din.readLine();
- }
-
- void readBooleans(boolean[] var1, int var2, int var3) throws IOException {
- int var5 = var2 + var3;
-
- while(var2 < var5) {
- int var4;
- if (!this.blkmode) {
- int var6 = Math.min(var5 - var2, 1024);
- this.field_0.readFully(this.buf, 0, var6);
- var4 = var2 + var6;
- this.pos = 0;
- } else {
- if (this.end - this.pos < 1) {
- var1[var2++] = this.din.readBoolean();
- continue;
- }
-
- var4 = Math.min(var5, var2 + this.end - this.pos);
- }
-
- while(var2 < var4) {
- var1[var2++] = Bits.getBoolean(this.buf, this.pos++);
- }
- }
-
- }
-
- void readChars(char[] var1, int var2, int var3) throws IOException {
- int var5 = var2 + var3;
-
- while(var2 < var5) {
- int var4;
- if (!this.blkmode) {
- int var6 = Math.min(var5 - var2, 512);
- this.field_0.readFully(this.buf, 0, var6 << 1);
- var4 = var2 + var6;
- this.pos = 0;
- } else {
- if (this.end - this.pos < 2) {
- var1[var2++] = this.din.readChar();
- continue;
- }
-
- var4 = Math.min(var5, var2 + (this.end - this.pos >> 1));
- }
-
- while(var2 < var4) {
- var1[var2++] = Bits.getChar(this.buf, this.pos);
- this.pos += 2;
- }
- }
-
- }
-
- void readShorts(short[] var1, int var2, int var3) throws IOException {
- int var5 = var2 + var3;
-
- while(var2 < var5) {
- int var4;
- if (!this.blkmode) {
- int var6 = Math.min(var5 - var2, 512);
- this.field_0.readFully(this.buf, 0, var6 << 1);
- var4 = var2 + var6;
- this.pos = 0;
- } else {
- if (this.end - this.pos < 2) {
- var1[var2++] = this.din.readShort();
- continue;
- }
-
- var4 = Math.min(var5, var2 + (this.end - this.pos >> 1));
- }
-
- while(var2 < var4) {
- var1[var2++] = Bits.getShort(this.buf, this.pos);
- this.pos += 2;
- }
- }
-
- }
-
- void readInts(int[] var1, int var2, int var3) throws IOException {
- int var5 = var2 + var3;
-
- while(var2 < var5) {
- int var4;
- if (!this.blkmode) {
- int var6 = Math.min(var5 - var2, 256);
- this.field_0.readFully(this.buf, 0, var6 << 2);
- var4 = var2 + var6;
- this.pos = 0;
- } else {
- if (this.end - this.pos < 4) {
- var1[var2++] = this.din.readInt();
- continue;
- }
-
- var4 = Math.min(var5, var2 + (this.end - this.pos >> 2));
- }
-
- while(var2 < var4) {
- var1[var2++] = Bits.getInt(this.buf, this.pos);
- this.pos += 4;
- }
- }
-
- }
-
- void readFloats(float[] var1, int var2, int var3) throws IOException {
- int var5 = var2 + var3;
-
- while(var2 < var5) {
- int var4;
- if (!this.blkmode) {
- var4 = Math.min(var5 - var2, 256);
- this.field_0.readFully(this.buf, 0, var4 << 2);
- this.pos = 0;
- } else {
- if (this.end - this.pos < 4) {
- var1[var2++] = this.din.readFloat();
- continue;
- }
-
- var4 = Math.min(var5 - var2, this.end - this.pos >> 2);
- }
-
- ObjectInputStream.access$700(this.buf, this.pos, var1, var2, var4);
- var2 += var4;
- this.pos += var4 << 2;
- }
-
- }
-
- void readLongs(long[] var1, int var2, int var3) throws IOException {
- int var5 = var2 + var3;
-
- while(var2 < var5) {
- int var4;
- if (!this.blkmode) {
- int var6 = Math.min(var5 - var2, 128);
- this.field_0.readFully(this.buf, 0, var6 << 3);
- var4 = var2 + var6;
- this.pos = 0;
- } else {
- if (this.end - this.pos < 8) {
- var1[var2++] = this.din.readLong();
- continue;
- }
-
- var4 = Math.min(var5, var2 + (this.end - this.pos >> 3));
- }
-
- while(var2 < var4) {
- var1[var2++] = Bits.getLong(this.buf, this.pos);
- this.pos += 8;
- }
- }
-
- }
-
- void readDoubles(double[] var1, int var2, int var3) throws IOException {
- int var5 = var2 + var3;
-
- while(var2 < var5) {
- int var4;
- if (!this.blkmode) {
- var4 = Math.min(var5 - var2, 128);
- this.field_0.readFully(this.buf, 0, var4 << 3);
- this.pos = 0;
- } else {
- if (this.end - this.pos < 8) {
- var1[var2++] = this.din.readDouble();
- continue;
- }
-
- var4 = Math.min(var5 - var2, this.end - this.pos >> 3);
- }
-
- ObjectInputStream.access$800(this.buf, this.pos, var1, var2, var4);
- var2 += var4;
- this.pos += var4 << 3;
- }
-
- }
-
- String readLongUTF() throws IOException {
- return this.readUTFBody(this.readLong());
- }
-
- private String readUTFBody(long var1) throws IOException {
- StringBuilder var3 = new StringBuilder();
- if (!this.blkmode) {
- this.end = this.pos = 0;
- }
-
- while(var1 > 0L) {
- int var4 = this.end - this.pos;
- if (var4 < 3 && (long)var4 != var1) {
- if (this.blkmode) {
- var1 -= (long)this.readUTFChar(var3, var1);
- } else {
- if (var4 > 0) {
- System.arraycopy(this.buf, this.pos, this.buf, 0, var4);
- }
-
- this.pos = 0;
- this.end = (int)Math.min(1024L, var1);
- this.field_0.readFully(this.buf, var4, this.end - var4);
- }
- } else {
- var1 -= this.readUTFSpan(var3, var1);
- }
- }
-
- return var3.toString();
- }
-
- private long readUTFSpan(StringBuilder var1, long var2) throws IOException {
- int var4 = 0;
- int var5 = this.pos;
- int var6 = Math.min(this.end - this.pos, 256);
- int var7 = this.pos + (var2 > (long)var6 ? var6 - 2 : (int)var2);
- boolean var8 = false;
-
- try {
- while(this.pos < var7) {
- int var9 = this.buf[this.pos++] & 255;
- switch (var9 >> 4) {
- case 0:
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- this.cbuf[var4++] = (char)var9;
- break;
- case 8:
- case 9:
- case 10:
- case 11:
- default:
- throw new UTFDataFormatException();
- case 12:
- case 13:
- byte var17 = this.buf[this.pos++];
- if ((var17 & 192) != 128) {
- throw new UTFDataFormatException();
- }
-
- this.cbuf[var4++] = (char)((var9 & 31) << 6 | (var17 & 63) << 0);
- break;
- case 14:
- byte var11 = this.buf[this.pos + 1];
- byte var10 = this.buf[this.pos + 0];
- this.pos += 2;
- if ((var10 & 192) != 128 || (var11 & 192) != 128) {
- throw new UTFDataFormatException();
- }
-
- this.cbuf[var4++] = (char)((var9 & 15) << 12 | (var10 & 63) << 6 | (var11 & 63) << 0);
- }
- }
- } catch (ArrayIndexOutOfBoundsException var15) {
- var8 = true;
- } finally {
- if (var8 || (long)(this.pos - var5) > var2) {
- this.pos = var5 + (int)var2;
- throw new UTFDataFormatException();
- }
-
- }
-
- var1.append(this.cbuf, 0, var4);
- return (long)(this.pos - var5);
- }
-
- private int readUTFChar(StringBuilder var1, long var2) throws IOException {
- int var4 = this.readByte() & 255;
- switch (var4 >> 4) {
- case 0:
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- var1.append((char)var4);
- return 1;
- case 8:
- case 9:
- case 10:
- case 11:
- default:
- throw new UTFDataFormatException();
- case 12:
- case 13:
- if (var2 < 2L) {
- throw new UTFDataFormatException();
- } else {
- byte var7 = this.readByte();
- if ((var7 & 192) != 128) {
- throw new UTFDataFormatException();
- }
-
- var1.append((char)((var4 & 31) << 6 | (var7 & 63) << 0));
- return 2;
- }
- case 14:
- if (var2 < 3L) {
- if (var2 == 2L) {
- this.readByte();
- }
-
- throw new UTFDataFormatException();
- } else {
- byte var5 = this.readByte();
- byte var6 = this.readByte();
- if ((var5 & 192) == 128 && (var6 & 192) == 128) {
- var1.append((char)((var4 & 15) << 12 | (var5 & 63) << 6 | (var6 & 63) << 0));
- return 3;
- } else {
- throw new UTFDataFormatException();
- }
- }
- }
- }
- }
-